package com.ak.demo;

import com.ak.demo.trigger.HelloTrigger;
import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

import java.time.LocalDateTime;
import java.util.Date;

public class MyHelloTrigger {
    public static void main(String[] args) throws SchedulerException {

        Scheduler scheduler= StdSchedulerFactory.getDefaultScheduler();

        JobDetail jobDetail= JobBuilder.newJob(HelloTrigger.class)
                .withIdentity("trigger","group1")
                .usingJobData("joker","data1")
                .build();

        Date start=new Date();
        start.setTime(System.currentTimeMillis()+3000);
        Date end=new Date();
        end.setTime(System.currentTimeMillis()+10000);
        Trigger trigger=TriggerBuilder.newTrigger()
                .withIdentity("trigger","group1")
                .startAt(start)
                .endAt(end)
                .build();
        scheduler.scheduleJob(jobDetail,trigger);

        scheduler.start();
    }
}
